package dao.Supper.impl;

import dao.BaseDao;
import dao.Supper.SuperAnnDao;
import pojo.Announcement;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class SuperAnnDaoImpl extends BaseDao implements SuperAnnDao {
    /**
     * 查询公告信息
     * @return
     */
    public List<Announcement> SelTitle() {
        List<Announcement> list = new ArrayList<>();
        try {
            String sql = "SELECT * FROM `announcement`";
            ResultSet rs = this.executeSelect(sql, null);
            while (rs.next()){
                Announcement ann = new Announcement();
                ann.setId(rs.getLong("id"));
                ann.setaTitle(rs.getString("aTitle"));
                ann.setaText(rs.getString("aText"));
                ann.setaDate(rs.getTimestamp("aDate"));
                list.add(ann);
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            closeAll();
        }
        return list;
    }
}
